package qlsl.androiddesign.adapter.subadapter;

import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.entity.otherentity.ShoppingDetail;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.TextSizeUtils;

/**
 * 订单列表<br/>
 *
 */
public class ShoppingOrderSellAdapter extends BaseAdapter<ShoppingDetail> {

	public ShoppingOrderSellAdapter(BaseActivity activity, List<ShoppingDetail> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_shopping_order_sell);

		ImageView iv_icon = getView(convertView, R.id.iv_icon);
		TextView tv_name = getView(convertView, R.id.tv_name);
		TextView tv_num = getView(convertView, R.id.tv_num);
		TextView tv_price_sell = getView(convertView, R.id.tv_price_sell);
		TextView tv_price_src = getView(convertView, R.id.tv_price_src);
		TextView tv_state = getView(convertView, R.id.tv_state);
		TextView tv_total = getView(convertView, R.id.tv_total);

		ShoppingDetail item = getItem(position);
		String name = item.getGoodsname();
		String price_new = "价格：￥" + item.getNewprice();
		String price_old = "￥" + item.getOldprice();
		String num = item.getNums();
		String state = item.getState();
		String space = activity.getString(R.string.space);
		if (state.equals("0")) {
			tv_state.setText("未支付");
		} else if (state.equals("1")) {
			tv_state.setText("已支付");
		}

		ImageUtils.rectOri(activity, item.getPhoto(), iv_icon);
		tv_name.setText(name);
		tv_num.setText("数量：" + num + "件");
		TextSizeUtils.setText(tv_price_sell, price_new, 3, price_new.length(), 14,
				activity.getResources().getColor(R.color.half_red));
		tv_price_src.setText(price_old);
		TextSizeUtils.setTextCenterLine(tv_price_src);
		tv_total.setText("共" + num + "件商品" + space + "合计：" + item.getPrice() + "元");

		return convertView;
	}
}
